#!/bin/bash
source /etc/profile




table=$1
keys='';values='';count=0;update=''
for i in $(mysql -uroot -proot -hhadoop3 -e 'desc result.res_oil'|awk 'NR != 1 {print $1","$2}')
do
line=($(echo $i|awk -F',' '{print $1,$2}'))
count=$(expr $count + 1)
key=${line[0]};is_num=${line[1]};
flag=0
if [[ $is_num == *decimal* ]] || [[ $is_num == *int* ]] || [[ $is_num == *double* ]]
then
 flag=1
fi
echo isnum:$is_num:$flag
if [[ $flag == '1' ]]
then
 values="$values,\$$count"
else
 values="$values,'\$$count'"
fi
keys="$keys,$key"
update="$update,$key=\$$count"
done

keys=${keys#,};values=${values#,};update=${update#,}
echo keys:$keys
echo values:$values
echo "replace into result.res_oil($keys) values($values)"
